#pragma once
#include "hash.h"

namespace xy {
	template<class K>
	struct SetKeyOfT{
		const K& operator()(const K& k) {
			return k;
		}
	};

	template<class K>
	class unordered_set {
	public:
		typedef hashTable<K, K, SetKeyOfT<K>> hash;
		typedef typename hash::const_iterator iterator;
		typedef typename hash::const_iterator const_iterator;

		iterator begin() const{
			return _ht.begin();
		}

		iterator end() const{
			return _ht.end();
		}

		iterator find(const K& k) {
			typename hash::iterator ret = _ht.find(k);
			return ret;
		}

		pair<iterator, bool> insert(const K& k) {
			pair<typename hash::iterator, bool> ret = _ht.insert(k);
			return make_pair(iterator(ret.first), ret.second);			
		}

		bool erase(const K& k) {
			return _ht.erase(k);
		}

		void print() {
			_ht.set_print();
			cout << endl;
		}
	private:
		hash _ht;
	};
}